﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
using System.Web.Mvc;
using XinYi.CrookedShow.BLL;
using XinYi.CrookedShowMode;

namespace XinYi.CrookedShowBack.Controllers
{
    public class HomeController : Controller
    {
        /// <summary>
        /// 分类表的业务逻辑层
        /// </summary>
        /// <returns></returns>
        
        MenuInformationService  menuInformationService = new MenuInformationService();
        public ActionResult Add_Article()
        {
            return View();
        }
        public ActionResult Add_Brand()
        {
            return View();
        }
        public ActionResult Add_Competence()
        {
            return View();
        }
            BrandService brandService = new BrandService();
            CategoryService categoryService = new CategoryService();
        public ActionResult Add_product()
        {
            Expression<Func<Brand, bool>> lambdaExpression1 = a => true;
            List<Brand> list1 = brandService.QueryList(lambdaExpression1);
            Expression<Func<Category, bool>> lambdaExpression2 = a => true;
            List<Category> list2 = categoryService.QueryList(lambdaExpression2);

            ViewBag.List1 = list1;
            ViewBag.List2 = list2;
            //ProductSpuView productSpu = new ProductSpuView();
            //ProductSkuView productSku = new ProductSkuView();
            //List<Pic> pics = new List<Pic>();
            //if (spuId > 0)
            //{
            //    productSpu = produc_Spu_Spec.GetProductSpuView(spuId);
            //}

            //ViewBag.productSpu = productSpu;
            //ViewBag.productSku = productSku;
            //ViewBag.pics = pics;
            return View();
        }
        
        public ActionResult Add_Singlepag()
        {
            return View();
        }
        public ActionResult Admin_Competence()
        {
            return View();
        }
        public ActionResult Administrator_list()
        {
            return View();
        }
        public ActionResult Advert_detailed_left()
        {
            return View();
        }
        public ActionResult Advertising_list()
        {
            return View();
        }
        public ActionResult Advertising_sort()
        {
            return View();
        }
        public ActionResult Article_list()
        {
            return View();
        }
        public ActionResult Brand_detailed()
        {
            return View();
        }
        public ActionResult Brand_Manage()
        {
            return View();
        }
        public ActionResult Price()
        {
            return View();
        }
        public ActionResult Price_add()
        {
            return View();
        }
        public ActionResult Price_update(int id)
        {
            PicService picService = new PicService();
            Expression<Func<Pic, bool>> lambdaExpression = a => a.Pic_Id == id;
            ViewBag.Pic= picService.Query(lambdaExpression);
            return View();
        }
        public ActionResult Update_Brand(int id)
        {
            BrandService brandService = new BrandService();
            Expression<Func<Brand, bool>> lambdaExpression = a => a.Id == id;
            ViewBag.Brand = brandService.Query(lambdaExpression);
            return View();
        }
        public ActionResult Columns()
        {
            return View();
        }
        public ActionResult Feedback()
        {
            return View();
        }
        public ActionResult Form_builder()
        {
            return View();
        }
        public ActionResult Home()
        {
            return View();
        }
        public ActionResult Houtaiguanli()
        {
            return View();
        }
        public ActionResult Index()
        {
            return View();
        }
        public ActionResult Interface()
        {
            return View();
        }
        public ActionResult Login()
        {
            return View();
        }
        public ActionResult Member_list()
        {
            return View();
        }
        public ActionResult Order()
        {
            OrderService orderService = new OrderService();
            //表达式
            Expression<Func<Order, bool>> ids = a => true;
            //调用查询方法返回一个集合
            List<Order> orderInfos = orderService.QueryList(ids);
            decimal count = 0;
            //循环遍历拿到交易金额
            for (int i = 0; i < orderInfos.Count; i++)
            {
                count += orderInfos[i].Order_Money;
            }
            ViewBag.Order_Money = count;
            ViewBag.Count = orderInfos.Count;
            return View();
        }
        public ActionResult Order_Chart()
        {
            return View();
        }
        public ActionResult Order_detailed()
        {
            return View();
        }
        public ActionResult Order_detaileds()
        {
            return View();
        }
        public ActionResult Order_form()
        {

            Expression<Func<Category, bool>> lambdaExpression = a => a.ParentId == 0;
            List<CategoryPercentage> list = new List<CategoryPercentage>();
            list = categoryService.categories();
            int count = 0;
            foreach (var item in list)
            {
                count += item.Count;
            }
            foreach (var item in list)
            {
                if (item.Count != 0)
                {
                    item.Count = Convert.ToInt32((item.Count * 100) / count);
                }
            }
            //百分比
            ViewBag.ListCategory = list;
            //菜单
            List<CategoryPercentage> ListMenuInformation = categoryService.categories();
            List<CategoryPercentage> ListMenuInformation2 = menuInformationService.categories();
            string shuzhi = "[";
            for (int i = 0; i < ListMenuInformation.Count; i++)
            {
                shuzhi += "{id:" + ListMenuInformation[i].Id + ",name:\"" + ListMenuInformation[i].Name + "\",amount:" + ListMenuInformation[i].Count + ",pid:" + ListMenuInformation[i].ParentId + "},";
                List<CategoryPercentage> List = ListMenuInformation2.Where(a => a.ParentId == ListMenuInformation[i].Id).ToList();
                for (int j = 0; j < List.Count; j++)
                {
                    shuzhi += "{id:" + List[j].Id + ",name:\"" + List[j].Name + "\",amount:" + List[j].Count + ",pid:" + List[j].ParentId + "},";
                }
                if (i + 1 == ListMenuInformation.Count)
                {
                    shuzhi += "]";
                }
            }
            ViewBag.shuzhi = shuzhi;
            return View();
        }
        public ActionResult Order_Logistics()
        {
            return View();
        }
        public ActionResult Page_list()
        {
            return View();
        }
        public ActionResult Payment_Configure()
        {
            return View();
        }
        public ActionResult Payment_details()
        {
            return View();
        }
        public ActionResult payment_method()
        {
            return View();
        }
        public ActionResult Personal_info()
        {
            return View();
        }
        public ActionResult Products()
        {
            return View();
        }
        public ActionResult Refund()
        {
            return View();
        }
        public ActionResult Refund_detailed()
        {
            return View();
        }
        public ActionResult Rizhi_list()
        {
            return View();
        }
        public ActionResult Shops_index()
        {
            return View();
        }
        public ActionResult Single_page_add()
        {
            return View();
        }
        public ActionResult System_columns()
        {
            return View();
        }
        public ActionResult System_info()
        {
            return View();
        }
    }
}